#/bin/bash
if [ "$1" == "" ]; then
  echo "$0 <IP address>"
else 
  if [ -f /root/.ssh/id_rsa ]; then
    echo "use old id_rsa"
  else 
    ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -P ''
    cp -rf /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
  fi
  ssh $1 "mkdir -p /root/.ssh/"
  scp /root/.ssh/id_rsa.pub $1:/root/.ssh/authorized_keys
  scp /root/.ssh/id_rsa $1:/root/.ssh/id_rsa 
  echo "Setup Done"
fi
